<template>
  <view>
    <button @click="testAdpcm">测试ADPCM编解码</button>
    <view>原始PCM: {{ pcmData.join(',') }}</view>
    <view>编码ADPCM: {{ adpcmData.join(',') }}</view>
    <view>解码PCM: {{ decodedPcm.join(',') }}</view>
  </view>
</template>

<script>
import { imaAdpcmEncode, imaAdpcmDecode } from '@/utils/ima-adpcm.js';

export default {
  data() {
    return {
      pcmData: [1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400], // 示例PCM数据
      adpcmData: [],
      decodedPcm: []
    }
  },
  methods: {
    testAdpcm() {
      // 编码
      const pcmArray = new Int16Array(this.pcmData);
      const adpcm = imaAdpcmEncode(pcmArray);
      this.adpcmData = Array.from(adpcm);

      // 解码
      const decoded = imaAdpcmDecode(adpcm);
      this.decodedPcm = Array.from(decoded);
    }
  }
}
</script> 